home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / ghostscr / ghostscr.zip / FONTS.DOC < prev    next >
Text File  |  1993-08-03  |  12KB  |  269 lines

  1.    Copyright (C) 1990, 1991 Aladdin Enterprises.  All rights reserved.
  2.  
  3. This file is part of Ghostscript.
  4.  
  5. Ghostscript is distributed in the hope that it will be useful, but
  6. WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
  7. to anyone for the consequences of using it or for whether it serves any
  8. particular purpose or works at all, unless he says so in writing.  Refer
  9. to the Ghostscript General Public License for full details.
  10.  
  11. Everyone is granted permission to copy, modify and redistribute
  12. Ghostscript, but only under the conditions described in the Ghostscript
  13. General Public License.  A copy of this license is supposed to have been
  14. given to you along with Ghostscript so you can know your rights and
  15. responsibilities.  It should be in a file named COPYING.  Among other
  16. things, the copyright notice and this notice must be preserved on all
  17. copies.
  18.  
  19. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  20.  
  21. This file, fonts.doc, describes the fonts and font facilities supplied
  22. with Ghostscript.
  23.  
  24. For an overview of Ghostscript and a list of the documentation files, see
  25. README.
  26.  
  27. About Ghostscript fonts
  28. =======================
  29.  
  30. The fonts included with Ghostscript come in several parts:
  31.  
  32.     - Font data in files *.gsf: each file defines one
  33.       (transformable) font specified in outline form.
  34.  
  35.     - BuildChar procedures in gs_fonts.ps: these provide the
  36.       algorithms for interpreting the data in the .gsf files.
  37.  
  38.     - The Fontmap file: this relates Ghostscript font names to .gsf
  39.       file names.
  40.  
  41. Currently, most of the fonts supplied with Ghostscript are based on
  42. various public domain bitmap fonts, primarily the ones supplied with the
  43. X11 distribution from MIT, and on the public domain Hershey fonts.  The
  44. fonts are distributed in the file `ghostscript-N.NNfonts.tar.Z'.  The
  45. bitmap-derived fonts include the usual Helvetica, Times-Roman, and so on;
  46. see the file `Fontmap' for the complete list, in the usual roman, italic,
  47. bold, and bold italic styles (for the most part).  The Hershey fonts, on
  48. the other hand, are quite different from traditional ones; the file
  49. `hershey.doc' describes them in more detail.
  50.  
  51. There is also a single rather heavy home-grown font called Ugly.  This
  52. font is the file `uglyr.gsf' in the Ghostscript source distribution.
  53.  
  54. The file gs_fonts.ps, which is loaded as part of Ghostscript
  55. initialization, arranges to load fonts on demand using the information
  56. from Fontmap.  If you want to preload all of the known fonts, invoke the
  57. procedure
  58.     loadallfonts
  59. This is not done by default, since the fonts occupy about 50K each and there
  60. are a lot of them.
  61.  
  62. Ghostscript fonts are actually ordinary Ghostscript programs: they use the
  63. extension .gsf instead of .ps simply to be informative.  This convention
  64. is only embodied in the Fontmap file: there is no code that knows about
  65. it.
  66.  
  67. If you want to try out the fonts, prfont.ps contains code for printing a
  68. sampler.  Load this program, by including it in the gs command line or by
  69. invoking
  70.     (prfont.ps) run
  71. and then to produce a sampler of a particular font, invoke
  72.     /fontName DoFont
  73. e.g.
  74.     /Times-Roman DoFont
  75.  
  76. Contents of fonts
  77. -----------------
  78.  
  79. A Ghostscript font is a dictionary with a standard set of keys as follows.
  80. The keys marked with a * have the same meanings as in P*stScr*pt fonts;
  81. those marked with # have the same meanings as in Adobe Type 1 fonts.  Note
  82. that FontName is required; StrokeWidth is required for all stroked or
  83. outlined fonts; and Metrics is not currently supported.
  84.  
  85. *    - FontMatrix <array>: the transformation from character
  86.       coordinates to user coordinates.
  87.  
  88. *    - FontType <integer>: the type of the font, either 1 or 3.
  89.  
  90. *    - FontBBox <array>: the bounding box of the font.
  91.  
  92. *    - Encoding <array>: the map from character codes to character
  93.       names.
  94.  
  95. *    - FontName <name>: the name of the font.
  96.  
  97. *    - PaintType <integer>: an indication of how to interpret the
  98.       character description from CharInfo.
  99.  
  100. *    - StrokeWidth <number>: the stroke width for outline fonts.
  101.  
  102. *    - FontInfo <dictionary>: additional information about the font
  103.       (optional, not used by the standard Ghostscript software).
  104.  
  105. *    - UniqueID <integer>: a unique number identifying the font.
  106.  
  107. *    - BuildChar <procedure>: the procedure for showing a character
  108.       (not required in type 1 fonts).
  109.  
  110. #    - CharStrings <dictionary>: the map from character names to character
  111.       descriptions (relevant only in type 1 fonts).
  112.  
  113. #    - Private <dictionary>: additional information used by the
  114.       algorithms for rendering outlines fonts (relevant only in type 1
  115.       fonts).
  116.  
  117. The format of values in the CharStrings and Private dictionaries are
  118. described in the Adobe Type 1 Font Format book.
  119.  
  120. Adding your own fonts
  121. =====================
  122.  
  123. Ghostscript can use any Type 1 or Type 3 font that is acceptable to other
  124. PostScript language interpreters.  Ghostscript also provides a way to
  125. construct a Type 1 font from a bitmap font in BDF format, which is a
  126. popular format in the Unix world.
  127.  
  128. If you want to add fonts of your own, you must edit Fontmap to include an
  129. entry for your new font at the end.  The format for entries is documented
  130. in the Fontmap file.  Since later entries in Fontmap override earlier
  131. entries, any fonts you add will supersede the corresponding fonts supplied
  132. with Ghostscript.  Note that the font name in the Fontmap entry must be
  133. the same as the FontName in the font itself.
  134.  
  135. In the PC world, Type 1 fonts are customarily given names ending in .PFA
  136. or .PFB.  Ghostscript can use these directly; you just need to make the
  137. entry in Fontmap.  If you are going to use a commercial Type 1 font (such
  138. as fonts obtained in conjunction with Adobe Type Manager) with
  139. Ghostscript, please read carefully the license that accompanies the font;
  140. Aladdin Enterprises and the Free Software Foundation take no
  141. responsibility for any possible violations of such licenses.
  142.  
  143. If you want to convert a BDF file to a scalable outline, use the program
  144. bdftops.ps (and invoking shell script bdftops.bat or bdftops).  Run the
  145. shell command
  146.     bdftops <BDF_file_name> [<AFM_file1_name> ...] <your_gsf_file_name>
  147.       <font_name> <uniqueID> [<encoding_name>]
  148. e.g.,
  149.     bdftops pzdr.bdf ZapfDingbats.afm pzdr.gsf ZapfDingbats 4100000
  150. Then make an entry for the .gsf file in Fontmap as described above.  You
  151. may find it helpful to read, and to add an entry to, the fonts.mak file,
  152. which is a makefile for converting the standard Ghostscript fonts.
  153.  
  154. Precompiling fonts
  155. ==================
  156.  
  157. You can compile any Type 1 font into C and link it into the Ghostscript
  158. executable.  (Type 1 fonts include any font whose name ends with .pfa or
  159. .pfb, and it also includes all the Ghostscript .gsf fonts except for the
  160. Hershey fonts.)  This doesn't have any effect on rendering speed, but it
  161. eliminates the time for loading the font dynamically, which may make a big
  162. difference in total rendering time, especially for multi-page documents.
  163. (Because of RAM and compiler limitations, you should only use compiled
  164. fonts on MS-DOS systems if you are using a 32-bit compiler such as Watcom
  165. C/386 or djgpp; you will run out of memory if you use compiled fonts with
  166. the Borland compiler.)  Fonts that have been precompiled and linked in
  167. this way do not need to appear in the Fontmap, although if they do appear
  168. there, no harm is done.
  169.  
  170. The utility for precompiling fonts is called font2c.  Note that font2c is
  171. a PostScript language program, so you must have Ghostscript already
  172. running to be able to run font2c; you must also have entries in the
  173. Fontmap for the fonts you want to compile.)  For example, to precompile
  174. the Times-Italic font,
  175.     font2c Times-Italic ptmri.c
  176. where the first argument is the font name and the second is the name of
  177. the .c file.  You can use any file name you want, as long as it ends in
  178. .c.  It doesn't have to be limited to 8 characters, unless your operating
  179. system requires this.  We suggest that you use names xxxx.c, where
  180. xxxx.gsf or xxxx.pfa is the name of the font file in the Fontmap file,
  181. just so you don't have to keep track of another set of names.  (If you are
  182. running on a VMS platform, or another platform where the C compiler has a
  183. limit on the length of identifiers, you must do something slightly more
  184. complicated; see the section 'Platforms with identifier length limits'
  185. below.  Also, on VMS, you must put quotes "" around the font name so that
  186. the VMS command processor doesn't convert the name to lower case.)
  187.  
  188. Besides running font2c, you must arrange things so that the file will be
  189. compiled from C to machine code, and linked into the executable.  All
  190. environments except VMS use the same procedure for this, which we will now
  191. describe.  For VMS environments, the necessary information is contained in
  192. comments in the command files (vms-cc.mak and vms-gcc.mak); if you are
  193. using Ghostscript on VMS, ignore the rest of this subsection.
  194.  
  195. First, you must add the compiled fonts "feature" to your
  196. platform-specific makefile.  On MS-DOS systems, you edit tc.mak,
  197. bc.mak, bcwin.mak, msc.mak, or watc.mak; on Unix systems, you edit
  198. makefile.  Find the definition of FEATURE_DEVS in the makefile, e.g.,
  199.     FEATURE_DEVS=filter.dev dps.dev
  200. Add ccfonts.dev on the end, e.g.,
  201.     FEATURE_DEVS=filter.dev dps.dev ccfonts.dev
  202.  
  203. Next, you must add the specific fonts to the generic makefile.  On MS-DOS
  204. systems, you edit gs.mak; on Unix systems, you edit makefile.  Find the
  205. line in the relevant makefile that says
  206.     ccfonts1_=ugly.$(OBJ)
  207. Edit this to add your compiled font file names, e.g.,
  208.     ccfonts1_=ugly.$(OBJ) ptmri.$(OBJ)
  209. If the line gets too long, add another line of the same form, e.g.,
  210.     ccfonts2_=ptmb.$(OBJ)
  211. Just below this, you will find a line that says
  212.     ccfonts1=Ugly
  213. Add your own fonts to the end of this line, e.g.,
  214.     ccfonts1=Ugly Times_Italic
  215. Notice that you must replace `-' by `_' in the font name.  Again, if
  216. the line gets too long, add another line of the same form, e.g.,
  217.     ccfonts1=Ugly
  218.     ccfonts2=Times_Italic
  219. Now find the lines that say
  220.     ugly.$(OBJ): ugly.c $(CCFONT)
  221.         $(CCCF) ugly.c
  222. Add a similar pair of lines for each font, separating these entries from
  223. the existing entries and from each other by a blank line.  (The makefile
  224. includes lines for a few more fonts than this already.)  In our example,
  225.     ugly.$(OBJ): ugly.c $(CCFONT)
  226.         $(CCCF) ugly.c
  227.  
  228.     ptmri.$(OBJ): ptmri.c $(CCFONT)
  229.         $(CCCF) ptmri.c
  230.  
  231. Finally, run `make'.  The executable will now include the fonts you added.
  232. They will be present in FontDirectory when Ghostscript starts up.
  233.  
  234. Note that ugly.c, ncrr.c, etc. are not supplied with the Ghostscript
  235. fileset, since they are quite large and can easily be recreated using the
  236. font2c program as described above.
  237.  
  238. Platforms with identifier length limits
  239. ---------------------------------------
  240.  
  241. On some platforms, the C compiler and/or linker have a limit on the number
  242. of significant characters in an identifier.  On such platforms, you must
  243. do a little extra work.
  244.  
  245. Let N be the maximum number of significant characters in an identifier
  246. (typically 31).  For each font whose name is longer than N-5 characters,
  247. pick an arbitrary identifier that we will call the "short name".  This can
  248. be any string you want, as long as it contains only letters, digits, and
  249. underscores; is no longer than N-5 characters; and is not the same as any
  250. other font name or short name.  A good choice for this would be to use the
  251. name of the C file.  (There is no harm in doing this for fonts with names
  252. shorter than N-5 characters, it's just not necessary.)
  253.  
  254. You must do two different things for fonts that require a short name.
  255. First, you must supply the short name as a third argument to the font2c
  256. program.  For example, to compile NewCenturySchlbk-BoldItalic using the
  257. short name "pncbi",
  258.     font2c NewCenturySchlbk-BoldItalic pncbi.c pncbi
  259. Then when you add the font to the gsaddmod line in the makefile, use the
  260. short name, not the actual font name, e.g.,
  261.     ccfonts2=pncbi
  262. instead of
  263.     ccfonts2=NewCenturySchlbk_BoldItalic
  264. Everything else is as described above.
  265.  
  266. This procedure doesn't change the name of the font in the Fontmap, or as
  267. seen from within Ghostscript; it's just a workaround for a limitation of
  268. some older compilers.
  269.